var  productClassName=500000;//每一行的id为，该行记录的id值+idLessValue
var sortNumber=200000;
var childrenNumber=100000;
var pic="<img src='common/images/plus.gif'>";
var pic1="<img src='common/images/nofollow.gif'>";

function updateSortValue1(tdname){
var tt=document.getElementById(tdname);
tt.innerHTML="<input type='text' name='kk' value="+tt.innerHTML+" onBlur='saveSortValue1("+tdname+",this)'>";
tt.onclick=function(){};
}

function updateProductValue1(tdname,ClassName){
var tt=document.getElementById(tdname);
tt.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;"+pic1+"<input type='text' name='kk' value="+ClassName+" onBlur='saveProductValue1("+tdname+",this)'>";
var valueNow=tt.innerHTML;
tt.onclick=function(){};
}
function saveSortValue1(tdname,dthis){//tdname为要更新行的id值，updateColumn表示要更新的列
var tt=document.getElementById(tdname);
tt.innerHTML=dthis.value;
tt.onclick=function(){
updateSortValue1(tdname);
};
 SendUpdateMessages("maintain_ProductClassAction_updateProductClass_post.do?id=" + (tdname-childrenNumber)+"&&sortNumber="+dthis.value);
}


function saveProductValue1(tdname,dthis){//tdname为要更新行的id值，updateColumn表示要更新的列
var tt=document.getElementById(tdname);
tt.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;"+pic1+dthis.value;
tt.onclick=function(){
updateProductValue1(tdname,dthis.value);
};
 SendUpdateMessages("maintain_ProductClassAction_updateProductClass_post.do?id=" + (tdname-productClassName)+"&&productClassName="+encodeURIComponent(dthis.value));
}

function updateSortValue(tdname){
var tt=document.getElementById(tdname);
tt.innerHTML="<input type='text' name='kk' value="+tt.innerHTML+" onBlur='saveSortValue("+tdname+",this)'>";
tt.onclick=function(){};
}


function updateProductValue(tdname,ClassName){
var tt=document.getElementById(tdname);
tt.innerHTML=pic+"<input type='text'  name='kk' value="+ClassName+" onBlur='saveProductValue("+tdname+",this)'>";
var valueNow=tt.innerHTML;
tt.onclick=function(){};
}


function saveSortValue(tdname,dthis){//tdname为要更新行的id值，updateColumn表示要更新的列
var tt=document.getElementById(tdname);
tt.innerHTML=dthis.value;
tt.onclick=function(){
updateSortValue(tdname);
};
 SendUpdateMessages("maintain_ProductClassAction_updateProductClass_post.do?id=" + (tdname-sortNumber)+"&&sortNumber="+dthis.value);
}

function saveProductValue(tdname,dthis){//tdname为要更新行的id值，updateColumn表示要更新的列
var tt=document.getElementById(tdname);
tt.innerHTML=pic+dthis.value;
tt.onclick=function(){
updateProductValue(tdname,dthis.value);
};
 SendUpdateMessages("maintain_ProductClassAction_updateProductClass_post.do?id=" + (tdname-productClassName)+"&&productClassName="+encodeURIComponent(dthis.value));
}

function Delete(id,trid) {
	if (confirm("你确定要删除这条记录吗?")) {
		SendMessages("maintain_ProductClassAction_deleteProductClass_get.do?id=" + id);
	}
 var k=document.getElementById(trid);
 k.parentNode.removeChild(k);
}

function SendMessages(url) {
	try {
		xmlhttp = new XMLHttpRequest();
	}
	catch (e) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
			//alert(xmlhttp);
			//当方法为post时需要如下设置http头
			//xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			//xmlhttp.setRequestHeader("If-Modified-Since","0");
			//xmlhttp.setRequestHeader("Cache-Control","no-cache");
			//打开连接，true表示异步提交
	xmlhttp.open("get", url, true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = callBackFunction;
}

function callBackFunction() {
	if (4 == xmlhttp.readyState) {
		if (200 == xmlhttp.status) {
			var data = xmlhttp.responseText;
			var message = document.getElementById("operateMessage");
			message.innerHTML = "<font color='red'>(" + data + ")</font>";
		} else {
			alert("error");
		}
	}
}

